home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / d3_global.ph < prev    next >
Encoding:
Text File  |  1994-04-25  |  8.7 KB  |  351 lines

  1. /*****************************************************************************
  2.   FILE           : d3_global.ph
  3.   SHORTNAME      : global.ph
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : type definitions and global defines
  7.   NOTES          : all global types are defined here
  8.                    this is the only module for global variables
  9.                    most varaibles are initilized
  10.                    the default values could be changed here
  11.  
  12.   AUTHOR         : Ralf Huebner
  13.   DATE           : 1.12.1991
  14.  
  15.   CHANGED BY     : Sven Doering, Niels Mache
  16.   IDENTIFICATION : @(#)d3_global.ph    1.11 3/2/94
  17.   SCCS VERSION   : 1.11
  18.   LAST CHANGE    : 3/2/94
  19.  
  20.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  21.  
  22. ******************************************************************************/
  23. #ifndef _D3GLOBAL_DEFINED_
  24. #define _D3GLOBAL_DEFINED_
  25.  
  26. /* begin global definition section */
  27.  
  28.  
  29. #ifndef D3_GLOBAL_DEFS
  30. #define D3_GLOBAL_DEFS
  31.  
  32.  
  33. #ifndef ZERO
  34. #define ZERO 0
  35. #endif
  36.  
  37.  
  38.  
  39. #define ANZ_VECS        9
  40. #define ANZ_LINES      12
  41. #define ANZ_PKT_LINE    2
  42. #define ANZ_FACETS      6
  43. #define ANZ_PKT_FACETS  4
  44.  
  45.  
  46.  
  47.  
  48. /*****************************************************************************
  49.    
  50.                              type definitions
  51.  
  52. ******************************************************************************/
  53.  
  54.  
  55.  
  56.  
  57. typedef float vector [4];         /* vector type */
  58. typedef float matrix [4][4];      /* matrix type */
  59. typedef vector cube [ANZ_VECS];   /* cube type   */
  60.  
  61.  
  62. typedef struct {                   /* polygon            */
  63.     int n;                         /* number of sides    */
  64.     int mask;                      /* interpolation mask */
  65.     vector vert[ANZ_PKT_FACETS];   /* vertices           */
  66. } d3_polygon_type;
  67.  
  68.  
  69.  
  70. typedef struct {                   /* unit_mode               */
  71.     int size;                      /* show value as size      */
  72.     int color;                     /* show value as color     */
  73.     int top_label;                 /* show value on top label */
  74.     int bottom_label;              /* show value bottom label */ 
  75. } d3_unit_mode_type;
  76.  
  77.  
  78.  
  79. typedef struct {                    /*  light_type                      */
  80.     int shade_mode;                 /*  shading mode                    */
  81.     vector position;                /*  light source position           */
  82.     float Ia;                       /*  ambient light intensity         */
  83.     float Ka;                       /*  ambient reflection coefficient  */
  84.     float Ip;                       /*  point light intensity           */
  85.     float Kd;                       /*  diffuse refection coefficient   */
  86. } d3_light_type;
  87.  
  88.  
  89.  
  90.  
  91.  
  92. typedef struct {
  93.     vector trans_vec, rot_vec, scale_vec;    /* translation, rotation, scale      */
  94.     vector trans_step, rot_step, scale_step; /* translation, rotation, scale step */
  95.     vector viewpoint;                        /* viewpoint for perspective         */
  96.     float unit_aspect;                       /* aspect beteen the size and  space */
  97.     float link_scale;                        /* scale for the links               */
  98.     float pos_link_trigger;                  /* positive trigger for the links    */
  99.     float neg_link_trigger;                  /* negative trigger for the links    */
  100.     int font;                                /* 3D font                           */
  101.     int projection_mode;                     /* central or parallel               */
  102.     int model_mode;                          /* solid or wireframe                */
  103.     int color_mode;                          /* mono or rgb                       */
  104.     int link_mode;                           /* shows link values                 */
  105.     d3_unit_mode_type  unit_mode;            /* shows unit values                 */
  106.     d3_light_type light;                     /* light source                      */
  107. } d3_state_type;
  108.  
  109.  
  110. typedef struct {                             /* WINDOW */
  111.      int x0, y0;                             /* xmin and ymin */
  112.      int x1, y1;                             /* xmax and ymax */
  113. } d3_window_type;
  114.  
  115.  
  116. struct d3_unitPtrDef {                       /* linear list type      */ 
  117.      int unitNo;                             /* key                   */
  118.      struct d3_unitPtrDef *next;             /* pointer to next item  */
  119. };
  120.  
  121.  
  122. typedef struct d3_unitPtrDef d3_unitPtrType;
  123.  
  124.  
  125. /*****************************************************************************
  126.    
  127.                              mode definitions
  128.  
  129. ******************************************************************************/
  130.  
  131.  
  132. /*   projection_mode   */
  133.  
  134. #define central         0
  135. #define parallel        1
  136.  
  137.  
  138.  
  139. /*   model_mode  */
  140.  
  141. #define wire_frame      0
  142. #define solid           1
  143.  
  144.  
  145.  
  146. /*   color_mode */
  147.  
  148. #define mono_mode       0
  149. #define gray_mode       1
  150. #define rgb_mode        2
  151.  
  152.  
  153.  
  154. /*   unit_mode   */
  155.  
  156. #define nothing_on      0
  157. #define activation_on   1
  158. #define init_act_on     2
  159. #define output_on       3
  160. #define bias_on         4
  161. #define name_on         5
  162. #define number_on       6
  163. #define zvalue_on       7
  164.  
  165.  
  166.  
  167. /*   link_mode   */
  168.  
  169. #define links_on        0
  170. #define links_off       1
  171. #define links_label     2
  172. #define links_color     3
  173.  
  174.  
  175.  
  176. /*   light_mode  */
  177.  
  178. #define shade_off       0
  179. #define shade_constant  1
  180.  
  181.  
  182. /*****************************************************************************
  183.    
  184.                                  makros
  185.  
  186. ******************************************************************************/
  187.  
  188.  
  189. #ifndef PI
  190. #define PI 3.1415926
  191. #endif
  192.  
  193.  
  194. #define rad(phi)  (phi / 180.0) * PI            /* radiant to degrees   */
  195. #define deg(phi)  (180.0 * phi) / PI            /* degrees to radiant   */
  196.  
  197. #define WAIT  {char ch; scanf ("%c", &ch);}     /* wait for a keystroke */
  198.  
  199.  
  200.  
  201.  
  202. /*****************************************************************************
  203.    
  204.                             global defines
  205.  
  206. ******************************************************************************/
  207.  
  208.  
  209.  
  210. /* X fonts */
  211.  
  212. #define d3_fontWidth 8
  213.  
  214. /* d3 fonts */
  215.  
  216. #define fnt5x8    0
  217. #define fnt8x14   1
  218. #define fnt5x7    2
  219.  
  220.  
  221. /* transformations */ 
  222.  
  223.  
  224. #define ROT_X_LEFT     0
  225. #define ROT_X_RIGHT    1
  226. #define ROT_Y_LEFT     2
  227. #define ROT_Y_RIGHT    3
  228. #define ROT_Z_LEFT     4
  229. #define ROT_Z_RIGHT    5
  230. #define TRANS_X_LEFT   6
  231. #define TRANS_X_RIGHT  7
  232. #define TRANS_Y_LEFT   8
  233. #define TRANS_Y_RIGHT  9
  234. #define TRANS_Z_LEFT  10
  235. #define TRANS_Z_RIGHT 11
  236. #define SCALE_PLUS    12
  237. #define SCALE_MINUS   13
  238.  
  239.  
  240.  
  241. /* selections for unit menu */
  242.  
  243. #define select_size      1
  244. #define select_color     2
  245. #define select_toplabel  3
  246. #define select_bottlabel 4
  247.  
  248.  
  249.  
  250. #endif
  251.  
  252.  
  253. /* Xlib and Xaw Variables */
  254.  
  255. Display      *d3_display;
  256. Window        d3_window;
  257. GC            d3_gc;
  258. int           d3_screen;
  259.  
  260.  
  261.  
  262.  
  263. /* Varibles to control the Windows */
  264.  
  265. int d3_displayXsize = 400;
  266. int d3_displayYsize = 400;
  267.  
  268. bool d3_displayIsReady = FALSE;
  269. bool d3_controlIsReady = FALSE;
  270.  
  271. bool d3_freeze = FALSE;
  272.  
  273. int d3_fontXsize, d3_fontYsize;
  274.  
  275. int d3_numberWidth = d3_fontWidth * 9;
  276. int d3_shortNumberWidth = d3_fontWidth * 6;
  277.  
  278. unsigned d3_textColor;
  279. float d3_intens;
  280.  
  281. d3_window_type d3_clipWindow;
  282.  
  283.  
  284.  
  285. /* the initial state structure */
  286.  
  287.  
  288. d3_state_type  d3_state = {
  289.     {0.0, 0.0, 0.0},               /* trans_vec         */
  290.     {0.0, 0.0, 0.0},               /* rot_vec           */
  291.     {1.0, 1.0, 1.0},               /* scale_vec         */
  292.     {10.0, 10.0, 10.0},            /* trans_step        */
  293.     {rad(10), rad(10), rad(10)},   /* rot_step          */
  294.     {1.1, 1.1, 1.1},               /* scale_step        */
  295.     {0.0, 0.0, -1000},             /* viewpoint         */
  296.     0.5,                           /* unit_aspect       */
  297.     5.0,                           /* link_scale        */
  298.     0.0, 0.0,                      /* link trigger      */
  299.     fnt8x14,                       /* font              */
  300.     parallel,                      /* projection_mode   */
  301.     wire_frame,                    /* model_mode        */
  302.     rgb_mode,                      /* color_mode        */ 
  303.     links_off,                     /* link_mode         */
  304.     {                              /* unit_mode         */
  305.          nothing_on,
  306.          nothing_on,
  307.          nothing_on,
  308.          nothing_on
  309.     },             
  310.     {                              /* light_mode        */
  311.          shade_constant,
  312.          {0.0, 0.0, -1000.0, 1.0},
  313.          0.2,      /* Ia */
  314.          1.0,      /* Ka */
  315.          0.7,      /* Ip */
  316.          1.0       /* Kd */
  317.     }
  318. };
  319.  
  320.  
  321.  
  322. /* unit cube  */
  323.  
  324.  
  325.  
  326. cube d3_e_cube = {
  327.     { 0.5,  0.5, -0.5,  0.5},
  328.     { 0.5,  0.5,  0.5,  0.5},
  329.     {-0.5,  0.5,  0.5,  0.5},
  330.     {-0.5,  0.5, -0.5,  0.5},
  331.     { 0.5, -0.5, -0.5,  0.5},
  332.     { 0.5, -0.5,  0.5,  0.5},
  333.     {-0.5, -0.5,  0.5,  0.5},
  334.     {-0.5, -0.5, -0.5,  0.5},
  335.     { 0.0,  0.0,  0.0,  0.5}
  336. };
  337.                      
  338.  
  339. /* end global definition section */
  340.  
  341. /* begin private definition section */
  342.  
  343. /* end private definition section */
  344.  
  345. #endif 
  346.  
  347. /* end of file */
  348. /* lines: 239 */
  349.  
  350.  
  351.